package cho114366.basic;

import java.util.Scanner;

public class J17_ProductMain {
	// 1
	private static String title = "배열을 이용한 상품 등록 프로그램";
	private static String menu = ">>>>(1) 추가 (2) 조회 (0) 종료";
	private static String addmsg = "번호,이름,설명,제조사,가격순으로 입력";
	private static String exitmsg = "프로그램을 종료합니다.";

	public static void main(String[] args) {
		// 2
		J17_product psrv = new J17_product();
		Scanner sc = new Scanner(System.in);

		// 3
		System.out.println(title);
		while (true) {
			System.out.println(menu);
			switch (sc.nextInt()) {
			case 1:
				addProduct(sc, psrv);
				break;
			case 2:
				showProduct(psrv);
				break;
			case 0:
				sc.close();
				System.out.println(exitmsg);
				System.exit(0);
				break;

			}//switch

		}//while

	}//main

	private static void showProduct(J17_product psrv) {
		System.out.println(psrv.readProduct());

	}

	private static void addProduct(Scanner sc, J17_product psrv) {
		System.out.println(addmsg);
		J17_ProductVO pvo = new J17_ProductVO(sc.next(), sc.next(), sc.next(),
				sc.next(), sc.nextInt());
		psrv.addProduct(pvo);

	}

}
